<?php
namespace Home\Controller;
use Think\Controller;
class ActivityController extends Controller
{
     public function activitylist(){
        //调用模型层获取数据
        $activitysmodel=M('activity');

    
    
        $activitys=$activitysmodel->table('activity a,club c')->where("a.c_id=c.c_id")->field('a.*,c.c_name')->select();
        
        
        $this->ajaxReturn($activitys,'JSON');

    }
      public function activitylists(){
        
      	$c_id=$_GET['c_id'];
      	         //调用模型层获取数据
        $activitysmodel=M('activity');

        $activitys=$activitysmodel->table('activity a,club c')->where("a.c_id=$c_id and a.c_id=c.c_id")->field('a.*,c.c_name')->select();
    
         //调用视图层显示数据
       
         $this->ajaxReturn($activitys,'JSON');

     }
     public function detail(){
     	$a_id=$_GET['a_id'];
        //调用模型层获取数据
        $detailmodel=M('activity');
    
        $detail=$detailmodel->table('activity a,club c')->where("a.a_id=$a_id and a.c_id=c.c_id")->field('a.*,c.c_name')->select();
        //调用视图层显示数据
        $this->detail=$detail;
       
        $this->ajaxReturn($detail,'JSON');

    }
    public function activityndetail(){
        $u_id=$_GET['u_id'];
        //调用模型层获取数据

        $activitynmodel=M('activityn');

        $activityn=$activitynmodel->table('activity a, activityn an,user u')->where("an.u_id=$u_id  and an.a_id=a.a_id and an.u_id=u.u_id")->field('an.*,u.u_name,a.a_name')->select();

     
        $this->activityn=$activityn;
      
        $this->ajaxReturn($activityn,'JSON');

    }
    // public function namedetail(){
    //     $u_id=$_GET['u_id'];
        
    //     //调用模型层获取数据

    //     $activitynmodel=M('activityn');

    //     $activityn=$activitynmodel->table('activity a, activityn an,user u')->where("an.u_id=$u_id  and an.a_id=a.a_id and an.u_id=u.u_id")->field('an.*,u.u_name,a.a_name')->select();

    //      $matchnmodel=M('matchn');

    //     $matchn=$matchnmodel->table('matchs m, matchn mn,user u')->where("mn.u_id=$u_id and mn.m_id=m.m_id and mn.u_id=u.u_id")->field('mn.*,u.u_name,m.m_name')->select();

    //     $trainnmodel=M('trainn');

    //     $trainn=$trainnmodel->table('train t, trainn tn,user u')->where("tn.u_id=$u_id and tn.t_id=t.t_id and tn.u_id=u.u_id")->field('tn.*,u.u_name,t.t_name')->select();


    //     $this->ajaxReturn(array($trainn,$activityn,$matchn),'JSON');
        
     

    // }
    public function addactivityn(){
        //调用模型层获取数据

    $data['u_id']=$_GET['u_id'];
    $data['a_id']=$_GET['a_id'];
    $data['an_paystate']=$_GET['an_paystate'];
    $data['createtime'] =  date("Y-m-d H:i:s"); 
    $activitynmodel=M('activityn');
    
    
  
                                              
    $activityn=$activitynmodel->add($data);

    if(false !==$activityn){
         
        
    $this->ajaxReturn(SUCCESS,'JSON');

    }else{
        //$this->false;
         $this->ajaxReturn($FALSE,'JSON');

    }
              
 

    }
}

